using System.Runtime.Serialization;

namespace SinBiota.Model.Business.MapServices.Datatypes
{
    public enum LayerType
    {
        Geography, // layer is based on geography objects from database
        HeatMap,   // layer is a heatmap based on a number of points and densities
        GeographyWithIntensity, // layer is based on geography objects from database, with an added intensity which determines the color, in a scale similar to a HeatMap.
    } ;

    [DataContract]
    public class TileLayer
    {
        [DataMember]
        public string Name { get; private set; }
        [DataMember]
        public string Key { get; private set; }
        [DataMember]
        public double Opacity { get; set; }
        [DataMember]
        public bool HasLegend { get; private set; }

        // not visible by service client:
        public LayerType LayerType { get; private set; }

        public TileLayerLegend TileLayerLegend { get; set; }

        // coloring:
        public GeographyDrawingStyle DrawingStyle;
        // stored proc. to get this layer from database
        public StoredProcedure StoredProcedure { get; set; }
        // only cached images: for very big layers, allows only cached images, to avoid going to DB, which is very expensive. 
        public bool ShowOnlyCachedImages { get; set; }

        // post paint in server:
        public bool PaintTile { get; set; }
        public TileLayer(string name, string key, LayerType type = LayerType.Geography)
        {
            Name = name;
            Key = key;
            Opacity = 0.7;
            LayerType = type;
            StoredProcedure = new StoredProcedure();
            DrawingStyle = new GeographyDrawingStyle();
            HasLegend = type == LayerType.GeographyWithIntensity;
            ShowOnlyCachedImages = false;
            PaintTile = true;
        }

        public override string ToString()
        {
            return string.Format("{0} ({1})", Name, Key);
        }
    }
}
